﻿using Estsh.Core.Base;
using Estsh.Core.Model.Extend.Models;
using Estsh.Core.Models;
using Estsh.Core.Repositories;
using Estsh.Core.Services;
using Estsh.Core.Wms.IRepositories;
using Estsh.Core.Wms.IServices;
using Estsh.Core.Wms.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Estsh.Core.Wms.Services
{
    public class OpenControlService : BaseService<BaseEntity>, IOpenControlService
    {
        private readonly IOpenControlRepository _repository;
        public OpenControlService(IOpenControlRepository iRepository) : base(iRepository)
        {
            _repository = iRepository;
        }

        public bool AddOrderCheck(int orderid, int pdlineid)
        {
            bool result = _repository.AddOrderCheck(orderid, pdlineid);
            return result;
        }

        public List<SysOrderCheck> GetOrderChecks(int id)
        {
            List<SysOrderCheck> orderChecks=_repository.GetOrderChecks(id);
            return orderChecks;
        }

        public List<SysOrderCheck> GetSysOrderChecks(string orderid)
        {
            List<SysOrderCheck> sysOrderChecks=_repository.GetSysOrderChecks(orderid);
            return sysOrderChecks;
        }

        public List<MesWorkOrder_Extend> GetOrders(int id)
        {
            List<MesWorkOrder_Extend> orders=_repository.GetOrders(id);
            return orders;
        }

        public List<MesWorkOrder_Extend> GetPartNoStatus(int id)
        {
            List<MesWorkOrder_Extend> orders = _repository.GetPartNoStatus(id);
            return orders;
        }

        public List<Syspdline_Extend> GetPdlines(int loginid)
        {
            List<Syspdline_Extend> pdlines = _repository.GetPdlineList(loginid);
            return pdlines;
        }

        public List<SysSpotCheck> GetSpotChecks(int id)
        {
            List<SysSpotCheck> spotChecks= _repository.GetSpotChecks(id);
            return spotChecks;
        }

        public List<MesWorkOrder> GetWorkOrder(int id)
        {
            List<MesWorkOrder> sysSpotChecks= _repository.GetWorkOrder(id);
            return sysSpotChecks;
        }

        public int UpdateCheckStatus(int id, string time)
        {
            int result = _repository.UpdateCheckStatus(id, time);
            return result;
        }

        public int UpdateCheckStatus(int orderid, int checkid, int status, int pdlineid,int loginid)
        {
            int result = _repository.UpdateCheckStatus(orderid, checkid, status,pdlineid,loginid);
            return result;
        }

        public int UpdateAgain(int orderid, int pdlineid, string loginid)
        {
            int result= _repository.UpdateAgain(orderid,pdlineid,loginid);
            return result;
        }

        public int UpdateWorkOrder(int orderid,int pdlineid)
        {
            int result=_repository.UpdateWorkOrder(orderid, pdlineid);
            return result;
        }

        public List<MesWorkOrder_Extend> GetCheckFinish(int pdlineid)
        {
            List<MesWorkOrder_Extend> result=_repository.GetCheckFinish(pdlineid);
            return result;
        }

        public List<SysSpotCheckReason> GetCheckReasons(int checkid)
        {
            List<SysSpotCheckReason> checkReasons=_repository.GetCheckReasons(checkid);
            return checkReasons;
        }

        public int AddReasonLog(int reasonid, int checkid,string loginid)
        {
            int result=_repository.AddReasonLog(reasonid, checkid,loginid);
            return result;
        }

        public int GetPdlineMaxCount(int pdlineid, int orderid)
        {
            int result = _repository.GetPdlineMaxCount(pdlineid,orderid);
            return result;
        }

        public List<MesWorkOrder_Extend> GetCheckOk(int orderid)
        {
            List<MesWorkOrder_Extend> result=_repository.GetCheckOk(orderid);
            return result;
        }
    }
}
